Units::teleport: update occupancy for the full EQUIPMENT footprint - #5924
Conversation
EQUIPMENT units (wagons) occupy a 3x3 footprint centered on their position, but teleport only cleared and set the unit occupancy bits on the center tile. Teleported wagons left stale unit flags on the eight surrounding source tiles and arrived with none set on the destination footprint, leaving the map occupancy inconsistent until something recomputed it (issue DFHack#5797). The footprint extent now comes from the race's EQUIPMENT_WAGON flag, so ordinary units keep the existing single-tile behavior.
de2b52e to
3a250e0
Compare
|
Holding this one until we know (from reverse engineering) whether the |
Verified that this is correct. |
SilasD
left a comment
There was a problem hiding this comment.
I know this one already got approved, but I do have a question.
(someday I'll learn the difference between commenting and reviewing. yesterday was not that day; it seems today isn't either.)
| // If there's already somebody standing at the destination, then force the unit to lay down | ||
| if (new_occ->bits.unit) | ||
| unit->flags1.bits.on_ground = true; |
There was a problem hiding this comment.
should this not also iterate over for_each_occupied_tile to see if any of the 1 (normally) or 9 (EQUIPMENT) tiles has a standing unit?
so that if there's a standing unit in any of the 9 tiles, the wagon arrives laying down.
coffee hasn't kicked in, so I'd like a second opinion.
Fixes #5797
Summary
Units::teleportonly cleared and set theunit/unit_groundedoccupancy bits on the unit's center tile. EQUIPMENT units such as wagons occupy a 3x3 footprint centered on their position, so a teleported wagon left stale flags on the eight surrounding source tiles and arrived with none set on the destination footprint.The footprint extent is now derived from the race's
EQUIPMENT_WAGONflag; ordinary units keep the existing single-tile behavior. The per-tile update logic is otherwise unchanged.Testing
Verified in a live fort against the rebuilt install by driving a synthetic wagon unit (race
EQUIPMENT_WAGON) throughdfhack.units.teleportand readingmap_block.occupancydirectly: